package com.bw.zg3.Tab

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.lifecycleScope
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.ToastUtils
import com.bw.base.mvvm.BaseFragment
import com.bw.zg3.Home.Apter.GGApter
import com.bw.zg3.Home.HomeViewModel
import com.bw.zg3.R
import com.bw.zg3.databinding.FragmentHomeBinding
import com.bw.zg3.notice.NoticeApter
import com.bw.zg3.notice.NoticeViewModel
import kotlinx.coroutines.launch


class HomeFragment :BaseFragment<FragmentHomeBinding,NoticeViewModel>(){
//    lateinit var ggApter: GGApter
    val noticeApter by lazy { NoticeApter() }
    override fun initView() {
//        ggApter = GGApter()
//        binding.rv.adapter = ggApter
//        vm.getGG(0,10)
        binding.rv.apply {
            adapter = noticeApter

        }
        lifecycleScope.launch {
            vm.getNotices().collect{
                noticeApter.submitData(it)
            }
        }
        //车位管理
        binding.car1.setOnClickListener {
            ARouter.getInstance().build("/app/Car1Activity").navigation()
        }



    }

    override fun intiData() {
//        vm.GGsuccecss.observe(this){
//            ggApter.data.clear()
//            ggApter.data.addAll(it)
//            ggApter.notifyDataSetChanged()
//            ToastUtils.showLong("请求数据成功")
//        }
    }

}